package teshop.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import teshop.data.dao.CatalogDAO;
import teshop.data.domain.Product;
import teshop.service.CatalogService;


/**
 * Catalog opportunities: add, remove, edit, view items
 * 
 * @author Hryhory Lira
 *
 */
@Service
public class CatalogServiceImpl implements CatalogService {
	
	private CatalogDAO catalogDAO;
	
	@Autowired
	public CatalogServiceImpl(CatalogDAO catalogDAO) {
		this.catalogDAO = catalogDAO;
	}

	@Override
	public List<Product> getItems(int firstItem, int size) {
		return catalogDAO.getItemsList(firstItem, size);
	}

	@Override
	public int getItemsCount() {
		return catalogDAO.getAll().size();
	}

	@Override
	public void addProduct(Product product) {
		catalogDAO.save(product);		
	}

}
